package com.zishi.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zishi.model.pojo.Category;
import com.zishi.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 文章分类表 前端控制器
 * </p>
 *
 * @author TP
 * @since 2022-05-05 08:53:41
 */
@RestController
@RequestMapping("/zishi/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 获取文章一级分类
     */
    @GetMapping("/1")
    public List<Category> getFirstClassification() {
        QueryWrapper<Category> wrapper = new QueryWrapper<>();
        wrapper.eq("level", 1);
        return categoryService.list(wrapper);
    }

    /**
     * 获取文章二级分类
     */
    @GetMapping("/2")
    public List<Category> getSecondClassification() {
        QueryWrapper<Category> wrapper = new QueryWrapper<>();
        wrapper.eq("level", 2);
        return categoryService.list(wrapper);
    }

}
